package com.jic.market.controller.rest;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.rest.CouponRestApi;
import com.jic.market.request.rest.coupon.*;
import com.jic.market.response.rest.coupon.QueryCouponPersonResponse;
import com.jic.market.response.rest.coupon.QueryCouponCenterResponse;
import com.jic.market.service.rest.coupon.CouponRestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author: wwb
 * @date: 2020-01-17
 * @remark:
 */
@RestController
@RequestMapping("/rest/coupon")
@Api(tags = {"优惠券H5接口"})
@Slf4j
public class CouponRestController implements CouponRestApi {

    @Resource
    private CouponRestService couponRestService;

    @ApiOperation("领券中心")
    @Override
    public RestResult<PageResult<QueryCouponCenterResponse>> queryCouponCenter(QuyerCouponCenterRequest quyerCouponCenterRequest) {
        return couponRestService.queryCouponCenter(quyerCouponCenterRequest);
    }

    @Override
    public RestResult<QueryCouponCenterResponse> queryCouponInfo(@Valid QuyerCouponCenterRequest quyerCouponCenterRequest) {
        return couponRestService.queryCouponInfo(quyerCouponCenterRequest);
    }

    @Override
    @ApiOperation(value = "当前商品可领取的优惠券列表")
    public RestResult<PageResult<QueryCouponCenterResponse>> queryCouponByThirdProductCode(CouponListOfGoodsRequest couponListOfGoodsRequest) {
        return couponRestService.queryCouponByThirdProductCode(couponListOfGoodsRequest);
    }

    @Override
    @ApiOperation(value = "领券接口")
    public RestResult<Boolean> receiveCoupon(CouponReceiveOfPersonRequest couponReceiveOfPersonRequest) {
        return couponRestService.receiveCoupon(couponReceiveOfPersonRequest);
    }

    @Override
    @ApiOperation(value = "个人优惠券列表")
    public RestResult<PageResult<QueryCouponPersonResponse>> couponListOfPerson(QueryCouponPersonRequest queryCouponPersonRequest) {
        return couponRestService.couponListOfPerson(queryCouponPersonRequest);
    }

    @Override
    @ApiOperation(value = "结算页查询优惠券列表")
    public RestResult<List<QueryCouponPersonResponse>> settlementMyCouponList(SettlementMyCouponRequest settlementMyCouponRequest) {
        return couponRestService.settlementMyCouponList(settlementMyCouponRequest);
    }

    @Override
    @ApiOperation("使用优惠券")
    public RestResult<Boolean> useCoupons(UseCouponRequest useCouponRequest) {
        return couponRestService.useCoupons(useCouponRequest);
    }

    @Override
    public RestResult<Boolean> returnCoupon(ReturnCouponRequest returnCouponRequest) {
        return couponRestService.returnCoupon(returnCouponRequest);
    }

    @Override
    public RestResult<PageResult<QueryCouponCenterResponse>> getPhoneCouponCenter(@Valid QuyerCouponCenterRequest quyerCouponCenterRequest) {
        return couponRestService.getPhoneCouponCenter(quyerCouponCenterRequest);
    }


}
